# # 基于Python官方镜像 3.11 3.12 都可以
# FROM python:3.11-slim

# # 设置环境变量
# ENV PYTHONDONTWRITEBYTECODE 1
# ENV PYTHONUNBUFFERED 1

# # 创建工作目录
# WORKDIR /app

# # 安装软件
# RUN apt-get -y install pkg-config

# # 安装依赖
# COPY requirements.txt /app/
# RUN pip install --upgrade pip && pip install -r requirements.txt

# # 拷贝项目
# COPY . /app/


FROM python:3.11-slim-bullseye


ARG APT_MIRROR=https://mirrors.aliyun.com
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=core-apt \
    --mount=type=cache,target=/var/lib/apt,sharing=locked,id=core-apt \
    sed -i "s@http://.*.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list \
    && rm -f /etc/apt/apt.conf.d/docker-clean \
    && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && apt-get update \
    && apt-get -y install --no-install-recommends pkg-config \
                                                  default-libmysqlclient-dev \
                                                  default-mysql-client \
                                                  gcc


# 设置环境变量
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1


# 创建工作目录
WORKDIR /app


# 安装依赖
COPY requirements.txt /app/
RUN pip install --upgrade pip && pip install -r requirements.txt

# 拷贝项目
COPY . /app/
